<template>
    <div class="sm-suptaskLastTable">
        <el-table
        ref="receiveTable"
        size="mini"
        :data="resData"
        style="width: 100%"
        height="190"
        highlight-current-row
        >
        <!-- <el-table-column type="selection" width="40"> </el-table-column> -->
        <el-table-column type="index" label="序号" width="50" :show-overflow-tooltip="true"> </el-table-column>
        <el-table-column prop="productCode" label="机型"  width="60" :show-overflow-tooltip="true"> </el-table-column> 
        <el-table-column prop="batchNo" label="批次" width="50"  :show-overflow-tooltip="true"> </el-table-column>
        <el-table-column prop="startPlaneNo" label="架次"  width="50" :show-overflow-tooltip="true"> </el-table-column>
        <el-table-column prop="itemCode" label="图号/型号"  :show-overflow-tooltip="true"> </el-table-column>
        <el-table-column prop="itemName" label="物料名称"  :show-overflow-tooltip="true"> </el-table-column>
        <el-table-column prop="itemQty" label="需求数量"   :show-overflow-tooltip="true"> </el-table-column>
        <el-table-column prop="itemType" label="物料类型"   :show-overflow-tooltip="true"> </el-table-column>
        <el-table-column prop="repartAss" label="装配图号" :show-overflow-tooltip="true"> </el-table-column>
        <el-table-column prop="packageCode" label="工作包编码"   :show-overflow-tooltip="true"> </el-table-column>
        <el-table-column prop="aoCode" label="AO编码"   :show-overflow-tooltip="true"> </el-table-column>
      </el-table>
        <!-- 分页 -->
        <el-pagination
            @size-change="handleSizeChange"
            @current-change="handleCurrentChange"
            :current-page="pageNumber"
            :page-sizes="[10,20,50,100]"
            :page-size="pageSize"
            layout="total, sizes, prev, pager, next, jumper"
            :total="totalCount">
        </el-pagination>
    </div>
</template>
<script>
import { supportingTaskLast } from "@/utils/api.js";
export default {
    name:'SuptaskLastTable',
    data(){
        return {
            // 当前页数
            pageNumber: 1,
            // 数据总个数
            totalCount: 0,
            // 返回的数据数组
            resData: [],
            // 每页数据个数
            pageSize: 20,
            // 接收mid传给last的info
            midLastInfo: "",
            ss: true,
        }
    },
    methods:{
         // 分页---每页数据条数
        handleSizeChange(val){
            this.pageSize = val;
            supportingTaskLast({
                msTaskAoId:this.midLastInfo,
                pageParameter: {
                rows: this.pageSize,
                page: this.pageNumber,
                },
            }).then((res) => {
                this.resData = res.data.responseBody.result;
                this.totalCount = res.data.responseBody.pageParameter.totalCount;
            });
        },
        // 分页---页数
        handleCurrentChange(val) {
            this.pageNumber = val;
                supportingTaskLast({
                        msTaskAoId:this.midLastInfo,
                    pageParameter: {
                    rows: this.pageSize,
                    page: this.pageNumber,
                    },
                }).then((res) => {
                    this.resData = res.data.responseBody.result;
                    this.totalCount = res.data.responseBody.pageParameter.totalCount;
                });
        },
    },
    mounted() {
        // 将msTaskAoId 传给lastTable进行查询数据
        this.$bus.$on('smStMidLastInfo',(e)=>{
            this.midLastInfo = e
                supportingTaskLast({
                    msTaskAoId:this.midLastInfo,
                    pageParameter: {
                        rows: this.pageSize,
                        page: this.pageNumber,
                    },
            }).then((res) => {
                this.resData = res.data.responseBody.result;
                this.totalCount = res.data.responseBody.pageParameter.totalCount;
                console.log('配套任务lastTable',res)
            }) 
        })
        this.$bus.$on('smStMidLastNull',(e)=>{
            this.resData = e
        })


        
  }
}
</script>
<style scoped>
.sm-suptaskLastTable {
    width: 100%;
    height: 220px;
    text-align: center;
}
</style>